'''
----案例：银行卡类----
编写一个银行卡类：
属性：银行名称、卡号、密码、姓名、余额
方法：登录、存款、取款
'''

class BankCard:
    bank_name = '中国银行'
    def __init__(self, bank_num, bank_pwd, name, balance):
        self.bank_num = bank_num
        self.bank_pwd = bank_pwd
        self.bank_name = name
        self.balance = balance

    def login(self):
        tag = 0
        bank_num = input('请输入银行卡号：')
        bank_pwd = input('请输入银行卡密码：')
        if bank_num == self.bank_num and bank_pwd == self.bank_pwd:
            tag =1
            print('恭喜你，登录成功')
        return tag
    def deposit(self):
        tag = self.login()
        if tag == 1:
            money = float(input('请输入存款金额：'))
            self.balance += money
            print('存款成功。当前余额为：', self.balance)
        else:
                print('请先登录')
    def withdraw(self):
        tag = self.login()
        if tag == 1:
            money = float(input('请输入取款金额:'))
            if money <= self.balance:
                self.balance -= money
                print('取款成功，当前余额为:',self.balance)
            else:
                print('取款失败，金额不足')
card = BankCard('1001','123','aaa',111111)
#card.assert()
card.deposit()
card.withdraw()



